package com.io.example.demoparent.simpleness.factory;


import com.io.example.demoparent.simpleness.CheesePizza;
import com.io.example.demoparent.simpleness.GreekPizza;
import com.io.example.demoparent.simpleness.Pizza;

/**
 * 简单工厂类
 */
public class SimpleFactory {

    /**
     * 简单工厂模型
     *
     * @param type
     * @return
     */
    public Pizza createPizza(String type) {
        Pizza pizza = null;
        switch (type) {
            case "greek": {
                pizza = new GreekPizza("希腊披萨");
                break;
            }
            case "cheese": {
                pizza = new CheesePizza("希腊披萨");
                break;
            }
            default: {
                pizza = new Pizza( ) {
                    @Override
                    public void prepare() {
                        System.out.println("以上无匹配信息，进入重试");
                    }
                };
            }
        }
        return pizza;
    }
}
